From: Lukas Lueg Date: Sat, 30 Sep 2017 14:51:42 +0000 (+0200) Subject: Allow multiple arguments in `cargo bench` X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6^2~22^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=df882fabd333d0a0d7fbc6193ea03c29ecf9dccf;p=cargo.git Allow multiple arguments in `cargo bench` Fixes #4504 --- diff --git a/src/bin/bench.rs b/src/bin/bench.rs index e3cacfac3..cb39fc9ce 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -48,13 +48,13 @@ Usage: Options: -h, --help Print this message --lib Benchmark only this package's library - --bin NAME Benchmark only the specified binary + --bin NAME ... Benchmark only the specified binary --bins Benchmark all binaries - --example NAME Benchmark only the specified example + --example NAME ... Benchmark only the specified example --examples Benchmark all examples - --test NAME Benchmark only the specified test target + --test NAME ... Benchmark only the specified test target --tests Benchmark all tests - --bench NAME Benchmark only the specified bench target + --bench NAME ... Benchmark only the specified bench target --benches Benchmark all benches --all-targets Benchmark all targets (default) --no-run Compile, but don't run benchmarks diff --git a/tests/bench.rs b/tests/bench.rs index 105b4029a..a2a2f21a6 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -150,6 +150,40 @@ fn bench_tarname() { .with_stdout_contains("test run2 ... bench: [..]")); } +#[test] +fn bench_multiple_targets() { + if !is_nightly() { return } + + let prj = project("foo") + .file("Cargo.toml" , r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("benches/bin1.rs", r#" + #![feature(test)] + extern crate test; + #[bench] fn run1(_ben: &mut test::Bencher) { }"#) + .file("benches/bin2.rs", r#" + #![feature(test)] + extern crate test; + #[bench] fn run2(_ben: &mut test::Bencher) { }"#) + .file("benches/bin3.rs", r#" + #![feature(test)] + extern crate test; + #[bench] fn run3(_ben: &mut test::Bencher) { }"#); + + assert_that(prj.cargo_process("bench") + .arg("--bench").arg("bin1") + .arg("--bench").arg("bin2"), + execs() + .with_status(0) + .with_stdout_contains("test run1 ... bench: [..]") + .with_stdout_contains("test run2 ... bench: [..]") + .with_stdout_does_not_contain("run3")); +} + #[test] fn cargo_bench_verbose() { if !is_nightly() { return }